package com.jbm.jbmsupplier.utlis;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 家帮忙 on 2017/4/10.
 */

public class ExitActivity {

    private ExitActivity(){};
    public static ExitActivity exitActivity;

    public static ExitActivity getInstance(){
        if (exitActivity==null){
            synchronized (ExitActivity.class){
                if (exitActivity==null){
                    exitActivity=new ExitActivity();
                }
            }
        }
        return exitActivity;

    }

    List<Activity> ListActivity=new ArrayList<>();
    //添加每个Activity
    public void addActivity(Activity activity){
        ListActivity.add(activity);
    }
    //销毁时调用
    public void deActivity(Activity activity){
        ListActivity.remove(activity);
    }


    //退出时调用
    public void exitActivity(){
        for (Activity activity:ListActivity){
            activity.finish();
        }
       // System.exit(0);
    }
    public void exitActivitys(){
        for (Activity activity:ListActivity){
            activity.finish();
        }
         System.exit(0);
    }




}
